<?php
/**
 * 求最近多少米距离的接口
 */
class Sx_near extends CI_Controller {
	/*执行操作*/
	var $action;
	/*X坐标*/
	var $x;
	/*Y坐标*/
	var $y;
	/*范围距离*/
	var $distance;
	var $cursor = 0;
	var $offset = 10;
	var $city;
	public function index() {
		$this -> action = $this -> input -> post('action');
		$this -> x = $this -> input -> post('pic_x');
		$this -> y = $this -> input -> post('pic_y');
		$this -> distance = $this -> input -> post('pic_distance');
		$this -> city = $this -> input -> post("city");
		$this -> cursor = $this -> input -> post("cursor");
		$this -> offset = $this -> input -> post("offset");
		if (empty($this -> action) || $this -> action != "getNear") {
			print($this -> fengchaoclass -> showhckmsg("1", NULL, $this -> lang -> line('hck_no'), TRUE));
			exit ;
		}

		empty($this -> cursor) ? $this -> cursor = 0 : $this -> cursor;
        empty($this -> offset) ? $this -> offset = 10 : $this -> offset;
		if($this->cursor <0){
			$this->cursor = 0;
		}
		if($this->offset <1){
			$this->offset = 1;
		}
		$this -> load -> model("sx_article_mod");
		$db =$this->sx_article_mod->getnear($this -> x, $this -> y, $this -> distance, $this -> cursor, $this -> offset , $this -> city);
		$rArr = array('Msg_error' => "0", 'Msg' => "", 'MsgTime' => date("Y-m-d H:i:s"));
		$rArr['total'] =$this->sx_article_mod->getnear($this -> x, $this -> y, $this -> distance, $this -> cursor, $this -> offset , $this -> city,TRUE);
		if (empty($db)) {
			$rArr['Resource'] = 0;
			$rArr['Msg_error'] = "18";
		} else {
			$rArr['Resource'] = $db;
			
		}

		//print_r($rArr);
       print(json_encode($rArr));
	}

}
?>